﻿@*@model IEnumerable<DOTNET_ASSIGNMENT.Models.Customer>*@

@model PagedList.IPagedList<DOTNET_ASSIGNMENT.Models.Customer>
@using PagedList.Mvc;
@{
    ViewBag.Title = "Index";
}

<p>
    @Html.ActionLink("Create New", "Create")
</p>

@using (Html.BeginForm("Manage", "Account", FormMethod.Get))
{
    <p>
        @Html.TextBox("SearchString", ViewBag.CurrentFilter as string, new { @placeholder = "Search Email..." })
        <input type="submit" value="Search" />
    </p>
}

<table>
    <tr>
        <th>
            @Html.ActionLink("Email", "Index", new { sortOrder = ViewBag.NameSortParm, currentFilter = ViewBag.CurrentFilter })
        </th>
      
        <th>
            <a href="#" name="Password">Password</a>
        </th>
       
        <th>
            @Html.ActionLink("Date", "Index", new { sortOrder = ViewBag.DateSortParm, currentFilter = ViewBag.CurrentFilter })
        </th>
        <th>
            @Html.ActionLink("Blocked", "Index", new { sortOrder = ViewBag.BlockSortParm, currentFilter = ViewBag.CurrentFilter })
        </th>
        <th></th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.Email)
        </td>
       
        <td>
            @Html.DisplayFor(modelItem => item.Password)
        </td>
        
        <td>
            @Html.DisplayFor(modelItem => item.Date)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.IsBlocked)
        </td>
        <td>
            @Html.ActionLink("Edit", "Edit", new { id=item.ID }) |
            @Html.ActionLink("Details", "Details", new { id=item.ID }) |
            @Html.ActionLink("Delete", "Delete", new { id=item.ID }) |
            @*@if(!item.IsBlocked)
            { 
                @Html.ActionLink("Block", "Block", new { email = item.Email })
            }
            else
            {
                @Html.ActionLink("Unblock", "Unblock", new { email = item.Email })
            }*@
        </td>
    </tr>
}
</table>
<span>Page</span> @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber) of @Model.PageCount

@Html.PagedListPager(Model, page => Url.Action("Index",
    new { page, sortOrder = ViewBag.CurrentSort, currentFilter = ViewBag.CurrentFilter }))
